package com.haiheng.moudule_visualinventoryrobot.adpter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.haiheng.library_base.adapter.BaseAdapter
import com.haiheng.moudule_visualinventoryrobot.R
import com.haiheng.moudule_visualinventoryrobot.databinding.LayoutItemMultiCameraBinding
import com.jiangdg.ausbc.MultiCameraClient

/**
 *
 * @Des:
 * @Author: hwz
 * @Date:2024/3/1 0001
 * @Version: 1.0
 */
class MultiCameraAdapter :BaseAdapter<MultiCameraClient.ICamera>() {

    init {
        addOnClickListener(R.id.multi_camera_capture_video)
        addOnClickListener(R.id.multi_camera_capture_image)
    }
    override fun onCreateViewBinding(viewType: Int): (LayoutInflater, ViewGroup, Boolean) -> ViewBinding {
       return LayoutItemMultiCameraBinding::inflate
    }

    override fun onItemView(
        holder: ViewBindHolder,
        position: Int,
        camera: MultiCameraClient.ICamera
    ) {
        camera ?: return

//        if (payloads.isEmpty()) {
//            return
//        }

        val binding = holder.binding as  LayoutItemMultiCameraBinding
        binding.multiCameraName.setText(camera.getUsbDevice().deviceName)

        // local update
        val switchIv = binding.multiCameraSwitch
        val captureVideoIv = binding.multiCameraCaptureVideo
//        if (payloads.find { "switch" == it } != null) {
//            if (camera.isCameraOpened()) {
//                switchIv.setImageResource(R.mipmap.ic_switch_on)
//            } else {
//                switchIv.setImageResource(R.mipmap.ic_switch_off)
//            }
//        }
//        if (payloads.find { "video" == it } != null) {
//            if (camera.isRecording()) {
//                captureVideoIv.setImageResource(R.mipmap.ic_capture_video_on)
//            } else {
//                captureVideoIv.setImageResource(R.mipmap.ic_capture_video_off)
//            }
//        }
    }
}